package org.lvhengchang.schoolmanager.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lvhengchang.schoolmanager.service.TeacherService;
import org.lvhengchang.schoolmanager.service.impl.TeacherServiceImpl;

/**
 * 教师删除操作处理类
 * 
 * @author LvHengchang
 *
 */
@WebServlet("/teacher/delete")
public class TeacherDeleteServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	private TeacherService teacherService = new TeacherServiceImpl();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String teacher_id = (String) req.getParameter("teacher_id");
		String teacher_name = (String) req.getParameter("teacher_name");

		try {
			teacherService.deleteTeacher(teacher_id);
			req.setAttribute("teacher_name", teacher_name);
			req.getRequestDispatcher("/teacher/teacher_delete_success.jsp").forward(req, resp);

		} catch (Exception e) {
			throw new ServletException(e);
		}

	}

}
